package cn.com.hp.feature.controller;

import cn.com.hp.feature.domain.dto.MenuInfoDTO;
import cn.com.hp.feature.domain.dto.OrderInfoDTO;
import cn.com.hp.feature.domain.entity.MenuInfo;
import cn.com.hp.feature.domain.entity.OrderInfo;
import cn.com.hp.feature.domain.vo.PageVO;
import cn.com.hp.feature.response.BaseResponse;
import cn.com.hp.feature.response.BaseResponseStatus;
import cn.com.hp.feature.service.IOrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: hjz
 * @since: 2022/9/1
 * @description:
 */
@RestController
@AllArgsConstructor
@RequestMapping("/order")
@Api(value = "订单管理", tags = "订单管理")
public class OrderInfoController {

    @Autowired
    private IOrderInfoService orderInfoService;

    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperation(value = "新增订单信息(小程序生成订单信息)", notes = "menuInfo")
    public BaseResponse<OrderInfo> save(@RequestBody OrderInfo orderInfo) {
        BaseResponse baseResponse = new BaseResponse();
        orderInfoService.save(orderInfo);
        baseResponse.setData(orderInfo);
        return baseResponse;
    }



    /**
     * 分页查询订单信息列表
     * @param orderInfoDTO
     * @return
     */
    @ApiOperation(value = "分页查询订单信息列表", notes = "分页查询订单信息列表")
    @ResponseBody
    @GetMapping("/page")
    public BaseResponse<PageVO<OrderInfo>> selectOderPage(OrderInfoDTO orderInfoDTO) {
        BaseResponse baseResponse = new BaseResponse(BaseResponseStatus.OK);
        PageVO<OrderInfo> dataList = orderInfoService.selectOderPage(orderInfoDTO);
        baseResponse.setData(dataList);
        return baseResponse;
    }

}
